package com.bsj.pay.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.bsj.pay.config.GlobalConfig;
import com.bsj.pay.service.AccountService;

@Component
public class UpdateAccountProxyTask
{
    @Autowired
    private AccountService accountService;
    
    private static boolean isReturn=true;
    
    @Scheduled(fixedRate = 2000)
    public void execute() {
        try {
            if (UpdateAccountProxyTask.isReturn&&GlobalConfig.isInit) {
                UpdateAccountProxyTask.isReturn = false;
                this.accountService.updateAccountProxyTask();
                UpdateAccountProxyTask.isReturn = true;
            }
        }
        catch (Exception e) {
            UpdateAccountProxyTask.isReturn = true;
        }
    }
}